// pages/user/user.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */

  data: {
    phone: '',
    name:'',
    wx_id:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log('openid=' +app.globalData.openid);
    var openid = app.globalData.openid;
    // var openid = 'efgh2';
    if (openid) {
      var that = this;
      wx.request({
        url: app.globalData.query_ip + '/wx_user_details',  // 查询用户信息
        method: 'GET',
        data: {
          openid: openid,
        },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          var d = res.data;
          that.setData({
            phone: d.phone,
            name: d.name,
            wx_id: d.wx_id,
          });
        },
      });
    } else {
      wx.redirectTo({
        url: '../login/login',
      })
    }
  },
  show_details:function(){
    var openid = app.globalData.openid;
    console.log('openid='+openid);
    wx.navigateTo({
      url: '../info_details/info_details?open_id=' + openid,
    })
  }
})